﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

using QLTTAN.DTO;
namespace QLTTAN.DAL
{
    public class LoaiLopHocDAL
    {
        ConnectionData conn;

        public DataTable LoaiLopHoc_Load()
        {
            conn = new ConnectionData();

            return conn.GetData("LOAILOPHOC_LOAD");
        }

        public int LoaiLopHoc_Insert(LoaiLopHocDTO LLH_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 2;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "TenLoaiLop";
            value[0] = LLH_DTO.TenLoaiLop;
            name[1] = "MaChuongTrinh";
            value[1] = LLH_DTO.MaChuongTrinh;

            return conn.UpdateData("LOAILOPHOC_INSERT", name, value, Nparameter);
        }

        public int LoaiLopHoc_Update(LoaiLopHocDTO LLH_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 3;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "MaLoaiLop";
            value[0] = LLH_DTO.MaLoaiLop;
            name[1] = "TenLoaiLop";
            value[1] = LLH_DTO.TenLoaiLop;
            name[2] = "MaChuongTrinh";
            value[2] = LLH_DTO.MaChuongTrinh;

            return conn.UpdateData("LOAILOPHOC_UPDATE", name, value, Nparameter);
        }

        public int LoaiLopHoc_Delete(LoaiLopHocDTO LLH_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 1;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "MaLoaiLop";
            value[0] = LLH_DTO.MaLoaiLop;

            return conn.UpdateData("LOAILOPHOC_DELETE", name, value, Nparameter);
        }
    }
}
